package com.zjc.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zjc.mapper.DromAdminMapper;
import com.zjc.mapper.StudentMapper;
import com.zjc.pojo.DromAdmin;
import com.zjc.pojo.StuRoom;
import com.zjc.pojo.Student;
import com.zjc.pojo.VisitTable;
import com.zjc.mapper.VisitTableMapper;
import com.zjc.service.VisitTableService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 周佳成
 * @since 2023-09-17
 */
@Service
public class VisitTableServiceImpl extends ServiceImpl<VisitTableMapper, VisitTable> implements VisitTableService {
	@Resource
	DromAdminMapper dromAdminMapper;
	@Resource
	StudentMapper studentMapper;
	@Resource
	VisitTableMapper visitTableMapper;
	@Override
	public boolean isMatch4Sgid2name(Integer id, String name) {
		LambdaQueryWrapper<DromAdmin> lambdaQueryWrapper =new LambdaQueryWrapper<>();
		lambdaQueryWrapper.eq(DromAdmin::getSgId,id);
		lambdaQueryWrapper.eq(DromAdmin::getSgName,name);
		return dromAdminMapper.selectOne(lambdaQueryWrapper) != null;
	}

	@Override
	public boolean isMatch4Stuid2name(Integer id, String name) {
		LambdaQueryWrapper<Student> lambdaQueryWrapper =new LambdaQueryWrapper<>();
		lambdaQueryWrapper.eq(Student::getStuId,id);
		lambdaQueryWrapper.eq(Student::getStuName,name);
		return studentMapper.selectOne(lambdaQueryWrapper) != null;
	}

	@Override
	public int deleteVis(Integer id) {
		LambdaQueryWrapper<VisitTable> lambdaQueryWrapper = new LambdaQueryWrapper<>();
		lambdaQueryWrapper.eq(VisitTable::getVtId,id);
		return visitTableMapper.delete(lambdaQueryWrapper);
	}
}
